﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ashlen.Portal.Core;
using Ashlen.Portal.Core.DataInterfaces;

namespace Ashlen.Portal.Data.SqlServer
{
    public class LookupDao : BaseDao, ILookupDao
    {
        public LookupDao() : base()
        {}

        public LookupDao(string connectionString)
            : base(connectionString)
        {}

        public object GetCountries() {
            RenewContext();
            var query = from c in Context.aspnet_Country
                        orderby c.Name ascending
                        select new { c.ID, c.Name };
            return query;
        }

        public object GetStates(string countryId)
        {
            RenewContext();
            var query = from s in Context.aspnet_State
                        where s.CountryID == countryId
                        orderby s.Name ascending
                        select new { s.ID, s.Name };
            return query;
        }


        public object GetUsers()
        {
            RenewContext();
            var query = from u in Context.aspnet_UserPersonalInfo
                        select new { Id = u.UserId, Name = u.Firstname + " " + u.Lastname };
            
            return query;
        }
    }
}
